﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="IsaRules.aspx.cs" Inherits="IsaRules" %>
<%@ OutputCache NoStore="true" Location="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Control internet access</title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="text-align: center"><b>Control Internet Access</b><br />
        <asp:HyperLink ID="reloadLink" runat="server" EnableViewState="False" NavigateUrl="~/IsaRules.aspx">[Refresh]</asp:HyperLink>
        <br /><br /></div>
    <div>
        <table runat="server" width="98%" align="center" style="border-collapse: collapse" cellpadding="4" cellspacing="1" border="0" id="mainTable">
        <tr>
            <td class="Title" style="width: 25%">Control access</td>
            <td class="DataA">
                <asp:DropDownList ID="ruleList" runat="server" AutoPostBack="True" 
                    DataSourceID="ruleSource" DataTextField="ruledesc" DataValueField="ruleid" 
                    onselectedindexchanged="ruleList_SelectedIndexChanged" 
                    ondatabound="ruleList_DataBound">
                </asp:DropDownList>
                <asp:RadioButtonList ID="activeList" runat="server" 
                    RepeatDirection="Horizontal" RepeatLayout="Flow">
                    <asp:ListItem Value="B">Block</asp:ListItem>
                    <asp:ListItem Value="A">Allow</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td class="TitleB">Expiry time HH:MM</td>
            <td class="DataB">
                <asp:TextBox ID="expirytimeText" runat="server"></asp:TextBox>
                <asp:Button ID="saveBut" runat="server" Text="Save" 
                    OnClientClick="return confirm('Are you sure? This may take a few seconds, be patient')" onclick="saveBut_Click" />
            </td>
        </tr>
        </table>
        <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="ruleid" DataSourceID="ruleSource" 
            HorizontalAlign="Center" SkinID="NewGridViewSkin" Width="98%">
            <Columns>
                <asp:BoundField DataField="ruledesc" HeaderText="Control" 
                    SortExpression="ruledesc" ItemStyle-Width="50%" />
                <asp:TemplateField HeaderText="Blocked" SortExpression="isactive" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="5%">
                    <ItemTemplate>
                        <img alt='<%# Eval("isactive") %>' src="<%# GetActiveImage(Container) %>" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="setby" HeaderText="Set by" 
                    SortExpression="setby" ItemStyle-Width="10%" />
                <asp:BoundField DataField="whenset" HeaderText="When set" 
                    SortExpression="whenset" ItemStyle-Width="15%" />
                <asp:BoundField DataField="autoclear" DataFormatString="{0:t}" 
                    HeaderText="Expires" HtmlEncode="False" SortExpression="autoclear" ItemStyle-Width="10%" />
            </Columns>
            <EmptyDataTemplate>
                No rules
            </EmptyDataTemplate>
        </asp:GridView>
    </div>
    <asp:SqlDataSource ID="ruleSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ISAControlConnectionString %>" 
        SelectCommand="SELECT * FROM [RuleInfo] ORDER BY [ruledesc], [ruleid]">
    </asp:SqlDataSource>
    </form>
</body>
</html>
